/**
*      author: Y_Yao
*      created: 2024-12-04 22:15:27
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 1e3 + 7;
int h[N],dp[N][N];
int n;

void solve()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> h[i];
    }

    int ans = 0;
    ans += n;
    for(int i = 1;i <= n;i++)
    {
        for(int j = i + 1;j <= n;j++)
        {
            dp[i][j] = 1;
            int d = h[j] - h[i];
            for(int k = 1;k < i;k++)
            {
                if(h[k] + d == h[i])
                {
                    dp[i][j] = (dp[k][i] + dp[i][j]) % mod;
                }
            }
            ans = (ans + dp[i][j]) % mod;
        }
    }

    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}